package panda.transaction.recovery;

import java.util.Iterator;

import panda.log.BasicLogRecord;
import panda.server.Panda;

public class LogRecordIterator implements Iterator<LogRecord> {
	private Iterator<BasicLogRecord> iterator = Panda.getLogManager()
			.iterator();

	public boolean hasNext() {
		return iterator.hasNext();
	}

	public LogRecord next() {
		BasicLogRecord record = iterator.next();
		int type = record.getInt();
		switch (type) {
		case LogRecord.CHECKPOINT:
			return new CheckPointRecord(record);
		case LogRecord.START:
			return new StartRecord(record);
		case LogRecord.COMMIT:
			return new CommitRecord(record);
		case LogRecord.ROLLBACK:
			return new RollbackRecord(record);
		case LogRecord.SETINT:
			return new SetIntRecord(record);
		case LogRecord.SETSTRING:
			return new SetStringRecord(record);
		case LogRecord.SETFLOAT:
			return new SetFloatRecord(record);
		case LogRecord.SETLONG:
			return new SetLongRecord(record);
		case LogRecord.SETARRAY:
			return new SetArrayRecord(record);
		default:
			return null;
		}
	}

	public void remove() {
	}

}
